﻿<Page x:Class="FacebookClient.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:ClientManager="clr-namespace:ClientManager;assembly=ClientManager"
    xmlns:ClientManagerControls="clr-namespace:ClientManager.Controls;assembly=ClientManager"
    xmlns:Facebook="clr-namespace:Contigo;assembly=Contigo"
    xmlns:FacebookClient="clr-namespace:FacebookClient"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
    xmlns:Properties="clr-namespace:FacebookClient.Properties"
    xmlns:shell="clr-namespace:Microsoft.Windows.Shell;assembly=Microsoft.Windows.Shell"
    xmlns:System="clr-namespace:System;assembly=mscorlib"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    AllowDrop="True"
    Background="{StaticResource FacebookBlueBrush}"
    ShowsNavigationUI="False"
    mc:Ignorable="PresentationOptions">
  <Border>
    <Grid x:Name="NavigationRoot">
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
      </Grid.RowDefinitions>
      <Grid Grid.Row="1">
        <Border x:Name="LayoutRootBorder">
          <Canvas>
            <Border x:Name="LayoutRoot" Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Canvas}}, Path=ActualWidth}" Height="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Canvas}}, Path=ActualHeight}">
              <Grid x:Name="MainContentGrid" Background="#FFFFFF">
                <Grid x:Name="AnimatedSwooshesContainer" ClipToBounds="True" IsHitTestVisible="False" Opacity=".65" />
                <!-- Restart Prompt. Collapsed by default -->
                <Grid x:Name="RestartPrompt" Width="350" Height="120" Background="LightBlue" Visibility="Collapsed" ZIndex="3">
                  <Border BorderBrush="Gray" BorderThickness="5" CornerRadius="3">
                    <Grid Width="310" Height="100" Background="LightBlue">
                      <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                      </Grid.RowDefinitions>
                      <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="100" />
                      </Grid.ColumnDefinitions>
                      <TextBlock Grid.ColumnSpan="2" Margin="5,0,0,0" FontSize="{DynamicResource LargeFontSize2}" TextWrapping="Wrap">
                          <Run Text="FishBowl has been updated. Would you like to restart now?" />
                      </TextBlock>
                      <Button Width="92" Height="27" Grid.Row="1" HorizontalAlignment="Right" Margin="10" Click="RestartNow" Content="Restart..." />
                      <Button Width="92" Height="27" Grid.Column="1" Grid.Row="1" Click="RestartLater" Content="Cancel" />
                    </Grid>
                  </Border>
                </Grid>
                <ClientManagerControls:MainContentContainer x:Name="ContentPane" AutomationProperties.AutomationId="ContentPane" KeyboardNavigation.DirectionalNavigation="None" KeyboardNavigation.IsTabStop="False" />
                <Button x:Name="BrowseBackButton" Command="NavigationCommands.BrowseBack" Style="{StaticResource BrowseBackButtonStyle}" />
              </Grid>
            </Border>
          </Canvas>
        </Border>
      </Grid>

      <Image x:Name="HeaderShadow" Height="6" Grid.Row="1" VerticalAlignment="Top" Source="Resources/Images/main_header_shadow.png" Stretch="Fill" Visibility="{Binding NavigationUIVisibility, RelativeSource={RelativeSource AncestorType={x:Type FacebookClient:MainWindow}}}" />
      <!--Visibility="{Binding NavigationUIVisibility, RelativeSource={RelativeSource AncestorType={x:Type FacebookClient:MainWindow}}}"-->
      <Grid x:Name="Header" Height="85" IsEnabled="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=IsOnline}" Visibility="{Binding NavigationUIVisibility, RelativeSource={RelativeSource AncestorType={x:Type FacebookClient:MainWindow}}}">
        <Grid x:Name="NavigationPanel" Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Bottom">
          <Grid.Resources>
            <Style TargetType="Rectangle">
              <Setter Property="Height" Value="23" />
              <Setter Property="Margin" Value="0" />
            </Style>
            <Style TargetType="TextBlock">
              <Setter Property="Foreground" Value="White" />
              <Setter Property="FontSize" Value="{DynamicResource SmallFontSize2}" />
              <Setter Property="FontFamily" Value="Resources/Fonts/#Gotham" />
              <Setter Property="FontWeight" Value="Light" />
              <Setter Property="VerticalAlignment" Value="Top" />
              <Setter Property="HorizontalAlignment" Value="Center" />
              <Setter Property="Margin" Value="4,5,4,0" />
            </Style>
          </Grid.Resources>
          <StackPanel Orientation="Horizontal">
            <RadioButton x:Name="HomeNavigationButton" Command="{Binding Path=NavigationCommands.NavigateHomeCommand, Source={x:Static ClientManager:ServiceProvider.ViewManager}}" IsChecked="True" Style="{StaticResource NavigationRadioButtonStyle}" ToolTip="See what's new with your friends">
              <StackPanel Orientation="Vertical">
                <Rectangle Fill="{StaticResource Home2DrawingBrush}" />
                <TextBlock Text="Home" />
              </StackPanel>
            </RadioButton>
            <RadioButton x:Name="FriendsNavigationButton" Command="{Binding Path=NavigationCommands.NavigateFriendsCommand, Source={x:Static ClientManager:ServiceProvider.ViewManager}}" Style="{StaticResource NavigationRadioButtonStyle}" ToolTip="Check in on your friends">
              <StackPanel Orientation="Vertical">
                <Rectangle Fill="{StaticResource StackedBuddiesDrawingBrush}" />
                <TextBlock Text="Friends" />
              </StackPanel>
            </RadioButton>
            <RadioButton x:Name="ProfileNavigationButton" Command="{Binding Path=NavigationCommands.NavigateProfileCommand, Source={x:Static ClientManager:ServiceProvider.ViewManager}}" Style="{StaticResource NavigationRadioButtonStyle}" ToolTip="Check in on yourself">
              <StackPanel Orientation="Vertical">
                <Rectangle Fill="{StaticResource SingleBuddyDrawingBrush}" />
                <TextBlock Text="Profile" />
              </StackPanel>
            </RadioButton>
            <RadioButton x:Name="PhotoAlbumsNavigationButton" Command="{Binding Path=NavigationCommands.NavigatePhotoAlbumsCommand, Source={x:Static ClientManager:ServiceProvider.ViewManager}}" Style="{StaticResource NavigationRadioButtonStyle}" ToolTip="See everyone's photos">
              <StackPanel Orientation="Vertical">
                <Rectangle Fill="{StaticResource PhotosDrawingBrush}" />
                <TextBlock Text="Photos" />
              </StackPanel>
            </RadioButton>
            <Button Click="_OnNotificationsClick" MouseDown="_OnNotificationsClick" Style="{StaticResource NavigationButtonStyle}" ToolTip="See Notifications">
              <Button.ContextMenu>
                <ContextMenu HorizontalOffset="-100" VerticalOffset="1" />
              </Button.ContextMenu>
              <StackPanel Orientation="Vertical">
                <Rectangle Fill="{StaticResource NotificationsDrawingBrush}" />
                <TextBlock Text="Notifications" />
              </StackPanel>
            </Button>
            <Image Style="{StaticResource NavigationSeparationStyle}" />
            <Button Click="GoToUploadsButton_Click" Style="{StaticResource NavigationButtonStyle}" ToolTip="Share more photos">
              <StackPanel Orientation="Vertical">
                <Rectangle Fill="{StaticResource AddPhotoDrawingBrush}" />
                <TextBlock Text="Upload" />
              </StackPanel>
            </Button>
            <Image Style="{StaticResource NavigationSeparationStyle}" />
            <Button Click="FBWebButton_Click" Style="{StaticResource NavigationButtonStyle}" ToolTip="Go to Facebook">
              <StackPanel Orientation="Vertical">
                <Rectangle Fill="{StaticResource FacebookDrawingBrush}" />
                <TextBlock Text="Facebook" />
              </StackPanel>
            </Button>
            <Image Style="{StaticResource NavigationSeparationStyle}" />
            <Button Click="_OnSignOutClicked" Style="{StaticResource NavigationButtonStyle}" ToolTip="Sign Out">
              <StackPanel Orientation="Vertical">
                <Rectangle Fill="{StaticResource ClosingDoorDrawingBrush}" />
                <TextBlock Text="Sign Out" />
              </StackPanel>
            </Button>
          </StackPanel>
        </Grid>
        <!-- Search Box -->
        <FacebookClient:CommandTextBox x:Name="SearchTextBox" Width="317" HorizontalAlignment="Right" Margin="0,5,11,0" VerticalAlignment="Top" CommitCommand="{Binding Source={x:Static ClientManager:ServiceProvider.ViewManager}, Path=NavigationCommands.NavigateSearchCommand}" CommitCommandParameter="{Binding ElementName=SearchTextBox, Path=Text}" IsEnabled="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=IsOnline}" KeyDown="SearchTextBox_KeyDown" Style="{StaticResource SearchTextBoxStyle}" Tag="Search" ToolTip="Search" />
        <!-- User Profile Image in background -->
        <ClientManagerControls:FacebookImageControl Margin="-40,0,0,0" FacebookImage="{Binding Source={x:Static ClientManager:ServiceProvider.ViewManager}, Path=MeContact.Image}" FacebookImageDimensions="Big">
          <ClientManagerControls:FacebookImageControl.Template>
            <ControlTemplate TargetType="{x:Type ClientManagerControls:FacebookImageControl}">
              <Border Width="250" HorizontalAlignment="Left">
                <Border.Background>
                  <ImageBrush ImageSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ImageSource}" Opacity=".4" Stretch="UniformToFill" />
                </Border.Background>
                <Border.OpacityMask>
                  <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                    <GradientStop Offset="0" Color="Black" />
                    <GradientStop Offset=".7" Color="Black" />
                    <GradientStop Offset="1" Color="Transparent" />
                  </LinearGradientBrush>
                </Border.OpacityMask>
              </Border>
            </ControlTemplate>
          </ClientManagerControls:FacebookImageControl.Template>
        </ClientManagerControls:FacebookImageControl>
        <!-- Logo and Status -->
        <StackPanel HorizontalAlignment="Left" Margin="12,9,0,0" Panel.ZIndex="10" VerticalAlignment="Top">
          <Grid Width="500" Height="40">
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="130" />
              <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <!--<Image Grid.Column="0" Width="130" Height="20" Margin="-8,-10,0,0" Source="Resources/Images/logo.png" VerticalAlignment="Top" HorizontalAlignment="Left"/>-->
            <TextBlock Grid.Column="1" Margin="0,1,0,3" VerticalAlignment="Bottom" FontFamily="Resources/Fonts/#Gotham" FontSize="{DynamicResource MiddleFontSize}" FontWeight="Light" Foreground="#c1d6ff" TextTrimming="CharacterEllipsis" TextWrapping="Wrap" ToolTip="{Binding Source={x:Static ClientManager:ServiceProvider.ViewManager}, Path=MeContact.StatusMessage.Message}">
                <TextBlock.Style>
                  <Style TargetType="{x:Type TextBlock}">
                    <Style.Triggers>
                      <DataTrigger Binding="{Binding Source={x:Static ClientManager:ServiceProvider.ViewManager}, Path=MeContact.StatusMessage.Message, FallbackValue={x:Static System:String.Empty}}" Value="">
                        <Setter Property="Visibility" Value="Hidden" />
                      </DataTrigger>
                    </Style.Triggers>
                  </Style>
                </TextBlock.Style>
                <TextBlock.Text>
                  <MultiBinding StringFormat="{}{0} {1}">
                    <Binding Path="MeContact.Name" Source="{x:Static ClientManager:ServiceProvider.ViewManager}" />
                    <Binding FallbackValue="" Path="MeContact.StatusMessage.Message" Source="{x:Static ClientManager:ServiceProvider.ViewManager}" />
                  </MultiBinding>
                </TextBlock.Text>
            </TextBlock>
          </Grid>
          <Image Width="357" Height="2" HorizontalAlignment="Left" Margin="157,3,0,3" VerticalAlignment="Top" SnapsToDevicePixels="True" Source="Resources/Images/main_header_status_divider.png" />
          <Canvas Width="400" HorizontalAlignment="Left" Margin="155,0,0,0" ClipToBounds="False">
            <FacebookClient:UpdateStatusControl Margin="-4,-4,0,0" IsEnabled="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=IsOnline}" />
          </Canvas>
        </StackPanel>
      </Grid>
      <!-- PhotoUploadWizard and disabled overlay. -->
      <Border x:Name="DisabledOverlay" Grid.RowSpan="2" Background="Black" Opacity="0" Visibility="Collapsed" />
      <Border x:Name="WizardParent" Width="405" Height="414" Grid.RowSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" Background="{StaticResource FacebookBlueBrush}" BorderBrush="DarkGray" BorderThickness="4" Opacity="0">
        <Border.Style>
          <Style TargetType="{x:Type Border}">
            <Style.Triggers>
              <Trigger Property="Opacity" Value="0">
                <Setter Property="Visibility" Value="Collapsed" />
              </Trigger>
            </Style.Triggers>
          </Style>
        </Border.Style>
        <Border.Effect>
          <DropShadowEffect x:Name="BorderShadow" ShadowDepth="2" />
        </Border.Effect>
        <Border.Triggers>
          <EventTrigger RoutedEvent="FacebookClient:PhotoUploadWizard.WizardShown">
            <BeginStoryboard>
              <Storyboard>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="DisabledOverlay" Storyboard.TargetProperty="(Grid.Visibility)">
                  <ObjectAnimationUsingKeyFrames.KeyFrames>
                    <DiscreteObjectKeyFrame KeyTime="0:0:0">
                      <DiscreteObjectKeyFrame.Value>
                        <Visibility>Visible
                        </Visibility>
                      </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                  </ObjectAnimationUsingKeyFrames.KeyFrames>
                </ObjectAnimationUsingKeyFrames>
                <BooleanAnimationUsingKeyFrames Storyboard.TargetName="DisabledOverlay" Storyboard.TargetProperty="(Grid.IsEnabled)" />
                <DoubleAnimation BeginTime="0:0:0" Duration="0:0:0.75" Storyboard.TargetName="DisabledOverlay" Storyboard.TargetProperty="(Grid.Opacity)" To="0.4" />
                <DoubleAnimation BeginTime="0:0:0" Duration="0:0:0.75" Storyboard.TargetName="WizardParent" Storyboard.TargetProperty="(Grid.Opacity)" To="1" />
              </Storyboard>
            </BeginStoryboard>
          </EventTrigger>
          <EventTrigger RoutedEvent="FacebookClient:PhotoUploadWizard.WizardHidden">
            <BeginStoryboard>
              <Storyboard>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="DisabledOverlay" Storyboard.TargetProperty="(Grid.Visibility)">
                  <ObjectAnimationUsingKeyFrames.KeyFrames>
                    <DiscreteObjectKeyFrame KeyTime="0:0:.75">
                      <DiscreteObjectKeyFrame.Value>
                        <Visibility>Collapsed
                        </Visibility>
                      </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                  </ObjectAnimationUsingKeyFrames.KeyFrames>
                </ObjectAnimationUsingKeyFrames>
                <DoubleAnimation BeginTime="0:0:0" Duration="0:0:0.75" Storyboard.TargetName="DisabledOverlay" Storyboard.TargetProperty="(Grid.Opacity)" To="0" />
                <DoubleAnimation BeginTime="0:0:0" Duration="0:0:0.75" Storyboard.TargetName="WizardParent" Storyboard.TargetProperty="(Grid.Opacity)" To="0" />
              </Storyboard>
            </BeginStoryboard>
          </EventTrigger>
        </Border.Triggers>
        <FacebookClient:PhotoUploadWizard x:Name="PhotoUploadWizard" />
      </Border>
    </Grid>
  </Border>
</Page>
